package com.ampaiva.view;

import junit.framework.TestCase;
import android.graphics.Point;
import android.graphics.Rect;

public class GeometryTest extends TestCase {

	public void testGetNearestMiddlePoints1() {
		// ...
		// .1.
		// ...
		// ...
		// .2.
		// ...
		Rect rect1 = new Rect(1, 1, 3, 3);
		Rect rect2 = new Rect(1, 4, 3, 6);
		Point[] points = Geometry.getNearestMiddlePoints(rect1, rect2);
		assertNotNull(points);
		assertEquals(2, points.length);
		assertEquals(new Point(2, 3), points[0]);
		assertEquals(new Point(2, 4), points[1]);
	}

	public void testGetNearestMiddlePoints10() {
		// ...
		// .1.
		// ...
		// ...
		// .2.
		// ...
		Rect rect1 = new Rect(10, 20, 30, 40);
		Rect rect2 = new Rect(10, 60, 30, 80);
		Point[] points = Geometry.getNearestMiddlePoints(rect1, rect2);
		assertNotNull(points);
		assertEquals(2, points.length);
		assertEquals(new Point(20, 40), points[0]);
		assertEquals(new Point(20, 60), points[1]);
	}

	public void testGetNearestMiddlePoints2() {
		// ......
		// .1..2.
		// ......
		Rect rect1 = new Rect(1, 1, 3, 3);
		Rect rect2 = new Rect(4, 1, 6, 3);
		Point[] points = Geometry.getNearestMiddlePoints(rect1, rect2);
		assertNotNull(points);
		assertEquals(2, points.length);
		assertEquals(new Point(3, 2), points[0]);
		assertEquals(new Point(4, 2), points[1]);
	}

	public void testGetNearestMiddlePoints3() {
		// ...
		// .2.
		// ...
		// ...
		// .1.
		// ...
		Rect rect2 = new Rect(1, 1, 3, 3);
		Rect rect1 = new Rect(1, 4, 3, 6);
		Point[] points = Geometry.getNearestMiddlePoints(rect1, rect2);
		assertNotNull(points);
		assertEquals(2, points.length);
		assertEquals(new Point(2, 3), points[1]);
		assertEquals(new Point(2, 4), points[0]);
	}

	public void testGetNearestMiddlePoints4() {
		// ......
		// .2..1.
		// ......
		Rect rect2 = new Rect(1, 1, 3, 3);
		Rect rect1 = new Rect(4, 1, 6, 3);
		Point[] points = Geometry.getNearestMiddlePoints(rect1, rect2);
		assertNotNull(points);
		assertEquals(2, points.length);
		assertEquals(new Point(3, 2), points[1]);
		assertEquals(new Point(4, 2), points[0]);
	}
}
